<template>
<view class="uni-padding-wrap uni-common-pb">
        <view class="uni-card">
            <view class="uni-card-header">{{actData.name}}</view>
            <view class="uni-card-content">
                <view class="uni-card-content-inner">
                {{actData.info}}
                </view>
            </view>
            <view class="uni-card-content">
                <view class="uni-card-content-inner">
                    <h3>活动须知</h3>
                    <p>活动时间：{{reTime}}</p>
                    <p>活动编号：49845616598765893432544</p>
                </view>
            </view>
            <view class="uni-card-footer"><button type="primary" @click="getSignUp">我要签到</button></view>
        </view>
		<view class="title">签到列表</view>
		<view class="uni-list">
			<view class="uni-list-cell" hover-class="uni-list-cell-hover" v-for="(value,key) in sign_lists" :key="key">
				<view class="uni-media-list">
					<view class="uni-media-list-logo">
						<image :src="value.avatarUrl"></image>
					</view>
					<view class="uni-media-list-body">
						<view class="uni-media-list-text-top">{{value.nickName}}</view>
						<view class="uni-media-list-text-bottom uni-ellipsis">{{value.time}}</view>
					</view>
				</view>
			</view>
		</view>
        <!-- 签到列表 -->
</view>
</template>
<script>
import {formatDate,get,post} from '@/utils/index';
import {getActDetails,getSignList,signUp} from '@/utils/api';
export default {
    data () {
        return {
            actData:{},
            test:'actData.name',
            sign_lists: [
                {
                "uid":1,
                "nickName":"路人甲",
                "age":"24"
                },
                {
                "uid":2,
                "nickName":"程小姐",
                "age":"21"
                }
            ],
            title: 'media-list',
            showImg: false,
            list: [{
                    title: "幸福",
                    content: "能和心爱的人一起睡觉，是件幸福的事情；可是，打呼噜怎么办？",
                    img: "https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/shuijiao.jpg?imageView2/3/w/200/h/100/q/90"
                },
                {
                    title: "木屋",
                    content: "想要这样一间小木屋，夏天挫冰吃瓜，冬天围炉取暖。",
                    img: "https://img-cdn-qiniu.dcloud.net.cn/uniapp/images/muwu.jpg?imageView2/3/w/200/h/100/q/90"
                }
            ],
            userInfo : uni.getStorageSync('userInfo')
        }
    },
    computed:{
        reTime(){
            return formatDate(this.actData.atime)
        }
    },
    mounted(){
        // console.log(formatTime(1546064719))
        this.init();
    },
    methods:{
        init(){
            this.getAct()
            let user  = uni.getStorageSync('userInfo')
            uni.connectSocket({
                url: 'wss://wx.igiky.cn/wss'
            });
            uni.onSocketMessage(function (res) {
                console.log('收到服务器内容：' , res);
                let obj = JSON.parse(res.data)
                // that.barrageList.push(obj)
            });
        },
        getAct(){
            var that = this;
            uni.showNavigationBarLoading();
            this.more  = true;
            get(getActDetails,{
                aid: 3
            }, true)
            .then((res)=>{
                console.log(res)
                this.actData = res.data.act
                this.sign_lists = res.data.signList
                uni.hideNavigationBarLoading();
            })
        },
        getSignUp(){
            post(signUp,{
                openid:this.userInfo.openid,
                actId:3,
                time:Math.round(new Date().getTime()/1000)
            }, true)
            .then((res)=>{
                if(res.code==0){
                    this.sign_lists.unshift(res.data)
                }                
                uni.showModal({
                    title: '提示',
                    content: res.msg,
                    showCancel:false,
                    success: function (res) {
                        if (res.confirm) {
                            console.log('用户点击确定');
                        } else if (res.cancel) {
                            console.log('用户点击取消');
                        }
                    }
                });
            })
        }
    },
    filters: {
      
    }

}
</script>

<style>
.page1{
    padding:10px;
}
</style>
